package main

import (
	"log"
	"net/http"
	"os"

	"gitee.com/lorock/goconfig"
	"github.com/fvbock/endless"
	"github.com/gorilla/mux"
)

func handler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("WORLD!"))
}

func main() {
	// 配置初始化
	goconfig.Init()
	port := goconfig.GetString("APP_SERVER_PORT")
	mux1 := mux.NewRouter()
	mux1.HandleFunc("/hello", handler).
		Methods("GET")

	err := endless.ListenAndServe("0.0.0.0:"+port, mux1)
	if err != nil {
		log.Println(err)
	}
	log.Println("Server on" + port + " stopped")

	os.Exit(0)
}
